package day05.KeTangDaiMa.NiMing;

interface Swimming {
    void swim();
}

public class Tset01 {
    public static void main(String[] args) {
        //通过匿名内部类实现
        goSwimming(new Swimming() {
            @Override
            public void swim() {
                System.out.println("铁汁, 我们去游泳吧");
            }
        });
        //通过Lambda表达式，对匿名内部进行优化！
        goSwimming(()->System.out.println("铁汁, 我们去游泳吧"));
    }


    /**
     * 使用接口的方法
     */
    public static void goSwimming(Swimming swimming){
        /*
            Swimming swim = new Swimming() {
                @Override
                public void swim() {
                    System.out.println("铁汁, 我们去游泳吧");
                }
            }
         */
        swimming.swim();
    }
}